//
//  AppDelegate.swift
//  ios8-01 weibo框架搭建
//
//  Created by blue on 16/2/26.
//  Copyright © 2016年 honeywell. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
       
       //设置全局导航条的颜色
       UIBarButtonItem.appearance().tintColor = UIColor.orangeColor()
        
       // NSThread.sleepForTimeInterval(2)
        
        //创建窗口
        self.window = UIWindow(frame:   UIScreen.mainScreen().bounds)
        
        //指定根控制器
        let tabBarVc = LWMainViewController()
        
        //self.window?.rootViewController = tabBarVc
                
        //self.window?.rootViewController = LWWelcomeViewController()
        self.window?.rootViewController = LWNewfeatureController()
        
        
        //显示窗口
       self.window?.makeKeyAndVisible()
        
        //关于版本号
        func  aboutVersion(){
            
            //2.获取当前版本号
            var  currentVersion = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String
            print("当前版本：\(currentVersion)")
            //1.从沙盒获取旧的版本号
            let  sandVersionKey = "sandVersionKey"
            let  sandVersion = NSUserDefaults.standardUserDefaults().stringForKey(sandVersionKey)
            //3.两个尽兴比较，把最新的版本号保存在沙盒
            print("就版本：\(sandVersion)")
            let  newVersion = currentVersion  !=  sandVersion!
            print("版本是否相同:\(newVersion)")
            //4.如果是最新的版本，要首先把它保存到沙盒则程序启动后要进入新特性界面，如果不是最新版本则进入欢迎界面
            if   newVersion{
                //进入新特性界面
                self.window?.rootViewController = LWNewfeatureController()
                
                NSUserDefaults.standardUserDefaults().setObject(currentVersion, forKey: sandVersionKey)
                
                NSUserDefaults.standardUserDefaults().synchronize()
                
            }else{
                
                self.window?.rootViewController = LWWelcomeViewController()
            }
            
        }
       
        
       return true
    }

  
}

